//    Copyright (C) Kherty.  All rights reserved.
using System;

namespace OpenLS.Spreadsheet.Extensibility
{
    public class AllowDateTimeToIntegerConversionAttribute : ParameterConverterAttribute
    {
        public AllowDateTimeToIntegerConversionAttribute()
            : base(ReferenceOption.ArgumentOrReference)
        {
        }
        internal override void ConvertImp(ConversionData data)
        {
            if (data.TargetType == typeof(int))
            {
                if (data.Value is DateTime)
                    data.Result = (int)data.Workbook.DateTimeToDouble((DateTime)data.Value);
            }
        }
    }
}